<?php
//TODO: ResumeWizard
class ExperienceResumeWizard extends Wizard
{
	var $table = "resume_experience";
	var $pfx = "resume_experience_";
	var $pid = "experience_resume_id";
	var $table_spheres;
	var $table_occupations;
	var $cat;
	var $sphere_main_cat;
	var $occupation_main_cat;
	function __construct(MyDB $db,$tablename = '',$pfx = '',$pid = '')
	{
		$this->db = $db;
		if(strlen($tablename) > 0){$this->table = mysql_real_escape_string($tablename);}
		if(strlen($pfx) > 0){$this->pfx = mysql_real_escape_string($pfx);}
		if(strlen($pid) > 0){$this->pid = mysql_real_escape_string($pid);}
		$this->table_spheres = $this->pfx.'sphere_tree';
		$this->table_occupations = $this->pfx.'occupation_tree';
		global $db_main;
		$this->cat = new CompanyCategoryWizard($db_main);
		$this->cat->db_item = $this->db;
		$this->sphere_main_cat = $this->cat->byAlias('sphere','job');
		$this->occupation_main_cat = $this->cat->byAlias('job','job');
	}
	//TODO: ResumeWizard::getResume()
	function getFullInfoById($id = 0)
	{
		$item = $this->getItem($id);
		if($item != false)
		{
			$item_id = intval($item['id']);
			$item['spheres'] = $this->getSpheres($item_id);
			$item['occupations'] = $this->getOccupations($item_id);
			return $item;
		}
		else return false;
	}
	function getSpheres($obj_id = 0,$display = 0)
	{
		if(intval($obj_id) != 0)
		{
			$list = $this->db->fetch_list("SELECT ".$this->cat->pid." FROM $this->table_spheres WHERE $this->pid = '".intval($obj_id)."'");
			if(!empty($list))
			{
				$items = array(
					'array' => $this->cat->getCatArray($list),
					'list' => $list
				);
				return $items; 
			}
			else return false;
		}
		else return false;
	}
	function getOccupations($obj_id = 0,$display = 0)
	{
		if(intval($obj_id) != 0)
		{
			$list = $this->db->fetch_list("SELECT ".$this->cat->pid." FROM $this->table_occupations WHERE $this->pid = '".intval($obj_id)."'");
			if(!empty($list))
			{
				$items = array(
					'array' => $this->cat->getCatArray($list),
					'list' => $list
				);
				return $items; 
			}
			else return false;
		}
		else return false;
	}
}
?>